Add a visual clue to indicate the projectiles are about to dissapear - #2801
Add a visual clue to indicate the projectiles are about to dissapear#2801Salonso928 wants to merge 3 commits into
Conversation
|
Play this branch at https://play.threadbare.game/branches/Salonso928/main/. (This launches the game from the start, not directly at the change(s) in this pull request.) |
manuq
left a comment
There was a problem hiding this comment.
The work you did looks good for the NO_EDIT_combat.tscn, which uses the NO_EDIT_projectile.tscn. But not with other projectiles, like ink_blob_projectile.tscn or any other projectile in StoryQuests.
I have more to comment about the visual clue (which is a great start, by the way), but let's fix this first!
| time_passed+=_delta | ||
| if time_passed>= time_to_dissapear && not is_dissapearing: | ||
| is_dissapearing=true | ||
| animation_player.play("dissapear") |
There was a problem hiding this comment.
This crashes the game if you play res://scenes/quests/lore_quests/quest_000/4_ink_combat/tutorial_ink_combat.tscn with:
E 0:00:08:038 projectile.gd:71 @ @implicit_ready(): Node not found: "%AnimationPlayer" (relative to "/root/TutorialInkCombat/InkBlobProjectile").
E 0:00:12:055 Projectile._process: Cannot call method 'play' on a null value.
…effect is only controlled by the projectile.gd script
|
Hi @manuq I made some changes. I removed the AnimationPlayer node, now the blink effect is only controlled by the projectile.gd script, therefore all the scenes that use this script should display the effect. Videocaptura.de.pantalla_20260828_120009.mp4 |
manuq
left a comment
There was a problem hiding this comment.
This looks good, although I think that the projectile should blink a predictable amount of times, let's say 3 blinks by default before dissapearing. Sorry that it wasn't part of the specification!
I understand that you switched from AnimationPlayer to make the blink programmatically because, as you saw, your first attempt changed only one of the 18 projectile scenes currently in the game.
There are pros and cons of doing it programmatically: the main benefit is that changing the script changes all 18 at the same time, great! But it leaves all the projectiles with the same look and feel. Someone wanting a different blink effect will need to duplicate the script. And artists wanting to improve the effect will be more comfortable editing it in an AnimationPlayer. Also we may want to add a sound effect in addition to the blink as audio clue.
Is fine if you want to keep doing it programmatically. I may add a followup ticket to move to AnimationPlayer. If so, check my suggestion to switch to Tween.
Alternatively, if you want to go back to AnimationPlayer you can make it optional, and add AnimationPlayer nodes to the NO_EDIT_projectile.tscn and the ink_blob_projectile.tscn, leaving the others (all StoryQuests) as before (without blink effect). For making it optional, you should not set a unique name (as I suggested before):
@onready var animation_player: AnimationPlayer = %AnimationPlayer
Because that will fail with Node not found: "%AnimationPlayer" in the scenes that don't have it. Instead you can export a new property:
@export var blink_animation_player: AnimationPlayer
Under @export_group("FXs"). And assign it in the 2 scenes mentioned above.
| ##the effect will start when the projectile has spent 70% of its lifetime | ||
| time_to_dissapear = duration * 0.7 | ||
|
|
||
| blink_timer = Timer.new() |
There was a problem hiding this comment.
Instead of using a Timer node to do the blinking, it would be better to use a Tween.
But this leads to my main feedback, whether or not to animate the blink effect programmatically. I'll comment about it separately.
| time_passed += _delta | ||
| if time_passed >= time_to_dissapear && not is_dissapearing: |
There was a problem hiding this comment.
The DurationTimer node is already tracking the time, you could check its time_left property. Or even better, create a separate Timer for this, and call it StartBlinkingTimer.
The _ready() method already does:
duration_timer.wait_time = duration
duration_timer.start()
So that's the place to setup the new timer:
duration_timer.wait_time = duration
duration_timer.start()
start_blinking_timer.wait_time = duration - blink_times * blink_duration
|
The lint and format checks are failing too for boring reasons (new lines and spacing). Please consider installing pre-commit as explained here. |
Affected scene: res://scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn
Affected script: res://scenes/game_elements/props/projectile/components/projectile.gd
When a projectile has spent the 80% of its duration, a dissapear animation will start. While this animation is playing the proyectile can be interacted with the repel comand and all Area2D nodes if posible, but this will no longer reset its duration.
An AnimationPlayer was added to the projectile scene and imported using the @onready annotation in the projectile.gd
Videocaptura.de.pantalla_20260827_193240.mp4
Fixes #2442